<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps({
  iconClass: {
    type: String,
    required: true,
    default: '组件'
  },
  className: {
    type: String
    // default: ''
  }
})
const svgClass = computed(() => {
  if (props.className) {
    return 'svg-icon ' + props.className
  } else {
    return 'svg-icon'
  }
})
const iconName = computed(() => {
  return `#icon-${props.iconClass}`
})
</script>

<style scoped lang="less">
.svg-icon {
  width: 1em; /* 1em = 16% of 100px */
  height: 1em; /* 1em = 16% of 100px */
  vertical-align: -0.15em; /* -0.15em = -0.15 * 16% = -2.4% */
  fill: currentColor;
  overflow: hidden;
}
</style>
